package com.gaohe.config;

import com.gaohe.interceptor.ProjectInterceptor;
import com.gaohe.interceptor.ProjectInterceptor2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private ProjectInterceptor interceptor;
//    @Autowired
//    private ProjectInterceptor2 interceptor2;
    //静态资源映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/pages/**")
                .addResourceLocations("classpath:/pages/");
    }
    //配置 拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/books","/books/*");
//        registry.addInterceptor(interceptor2)
//                .addPathPatterns("/books","/books/*");
    }
}
